import Taro,{Component}from '@tarojs/taro'
import {View} from "@tarojs/components"
import {AtTabBar, AtTabs, AtTabsPane} from 'taro-ui'
import MyClass from '../class/index'
import Tools from '../tools/index'
import My from '../my/index'
import './index.scss'

export default class Index extends Component{
  constructor(props) {
    super(props);
    this.handleClick = this.handleClick.bind(this);
    this.state = {
      current:0
    }
  }
 handleClick(value){
    this.setState({
      current:value
    })
 }
  render() {

    const tabList = [
      {title:'班级',iconPrefixClass:'icon',iconType:'-banji-danse'},
      {title:'工具',iconPrefixClass:'icon',iconType:'yingyong-copy'},
      {title:'我的',iconPrefixClass:'icon',iconType:'wode'}

    ]
    const {current} = this.state;
    return(
          <View>
            <AtTabs current={current} tabList={tabList} swipeable onClick={this.handleClick}>
              <AtTabsPane current={current} index={0}>
                {current === 0 && <MyClass />}
              </AtTabsPane>
              <AtTabsPane current={current} index={1}>
                {current === 1 && <Tools />}
              </AtTabsPane>
              <AtTabsPane current={current} index={2}>
                {current === 2 && <My />}
              </AtTabsPane>

            </AtTabs>
            <AtTabBar
              fixed
              tabList={tabList}
              onClick={this.handleClick}
              current={current}
              iconSize={24}
            />
          </View>
    )
  }

}
